package com.jubao.modules.sys.service.impl;

import java.util.List;
import java.util.Map;

import com.jubao.modules.sys.dao.BankTypeMapper;
import com.jubao.modules.sys.entity.BankTypeEntity;
import com.jubao.modules.sys.service.BankTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jubao.common.entity.Page;
import com.jubao.common.entity.Query;
import com.jubao.common.entity.R;
import com.jubao.common.utils.CommonUtils;

/**
 * 资产类型
 * @author jubaodai<363217237@qq.com>
 */
@Service("bankTypeService")
public class BankTypeServiceImpl implements BankTypeService {

	@Autowired
    private BankTypeMapper bankTypeMapper;

    /**
     * 分页查询
     * @param params
     * @return
     */
	@Override
	public Page<BankTypeEntity> listBankType(Map<String, Object> params) {
		Query query = new Query(params);
		Page<BankTypeEntity> page = new Page<>(query);
		bankTypeMapper.listForPage(page, query);
		return page;
	}

    /**
     * 新增
     * @param bankType
     * @return
     */
	@Override
	public R saveBankType(BankTypeEntity bankType) {
		int count = bankTypeMapper.save(bankType);
		return CommonUtils.msg(count);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public R getBankTypeById(Long id) {
		BankTypeEntity bankType = bankTypeMapper.getObjectById(id);
		return CommonUtils.msg(bankType);
	}

	@Override
	public R getTypeNames() {
		List<String> names = bankTypeMapper.getTypeNames();
		return CommonUtils.msg(names);
	}

	/**
     * 修改
     * @param bankType
     * @return
     */
	@Override
	public R updateBankType(BankTypeEntity bankType) {
		int count = bankTypeMapper.update(bankType);
		return CommonUtils.msg(count);
	}

    /**
     * 删除
     * @param id
     * @return
     */
	@Override
	public R batchRemove(Long[] id) {
		int count = bankTypeMapper.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
